Skip to content

Commit 2dbacc7

Browse files
Temp celery switch for question moderation (#6688)
* Temp celery switch for question moderation * fix lint issue --------- Co-authored-by: Ryan Johnson <rjohnson@mozilla.com>
1 parent 7bb879d commit 2dbacc7

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

kitsune/questions/models.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import actstream
99
import actstream.actions
10+
import waffle
1011
from django.conf import settings
1112
from django.contrib.auth.models import User
1213
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
@@ -190,6 +191,7 @@ def clear_cached_contributors(self):
190191

191192
def save(self, update=False, *args, **kwargs):
192193
"""Override save method to take care of updated if requested."""
194+
193195
new = not self.id
194196

195197
if not new:
@@ -203,8 +205,21 @@ def save(self, update=False, *args, **kwargs):
203205
# actstream
204206
# Authors should automatically follow their own questions.
205207
actstream.actions.follow(self.creator, self, send_action=False, actor_only=False)
206-
# Either automatically classify the question or add it to the moderation queue
207-
question_classifier.delay(self.id)
208+
if waffle.switch_is_active("flagit-spam-autoflag"):
209+
from kitsune.questions.utils import flag_question
210+
from kitsune.users.models import Profile
211+
212+
flag_question(
213+
self,
214+
by_user=Profile.get_sumo_bot(),
215+
notes=(
216+
"Automatically flagged for topic moderation:"
217+
" flagit-spam-autoflag is active"
218+
),
219+
)
220+
else:
221+
# Either automatically classify the question or add it to the moderation queue
222+
question_classifier.delay(self.id)
208223

209224
def add_metadata(self, **kwargs):
210225
"""Add (save to db) the passed in metadata.

0 commit comments

Comments
 (0)